package com.ogawa.chair7808.adapter;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ogawa.base.utils.DebugUtils;
import com.ogawa.chair7808.R;
import com.ogawa.chair7808.utils.Activity7808Utils;
import com.ogawa.chair7808.view.AutoProgramBean;

import org.jetbrains.annotations.NotNull;

public class AutoProgramAdapter extends BaseQuickAdapter<AutoProgramBean, BaseViewHolder> {
    public AutoProgramAdapter() {
        super(R.layout.layout_auto_program_item);

    }

    @NotNull
    @Override
    protected BaseViewHolder createBaseViewHolder(@NotNull View view) {
        int height = getRecyclerView().getHeight() / getItemCount();
        view.getLayoutParams().height = height;
        return super.createBaseViewHolder(view);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, AutoProgramBean autoProgramBean) {


        baseViewHolder.setImageResource(R.id.iv, autoProgramBean.getImageRes())
                .setText(R.id.tv, autoProgramBean.getName())
                ;
        ImageView iv = baseViewHolder.getView(R.id.iv);
//        iv.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if (DebugUtils.isDebug){
//                    Activity7808Utils.startProMasDetailActivity(getContext(), autoProgramBean.getName());
//                }
//            }
//        });
        iv.setSelected(autoProgramBean.isSelect());
    }
}
